package com.example.jasonrpc.client;

import com.example.jasonrpc.codec.Decoder;
import com.example.jasonrpc.codec.Encoder;
import com.example.jasonrpc.codec.JSONDecoder;
import com.example.jasonrpc.codec.JSONEncoder;
import com.example.jasonrpc.proto.Peer;
import com.example.jasonrpc.transport.HttpTransportClient;
import com.example.jasonrpc.transport.TransportClient;

import java.util.Collections;
import java.util.List;

public class RpcClientConfig {
    private Class<? extends TransportClient> transportClient;
    private Class<? extends Encoder> encoderClass;
    private Class<? extends Decoder> decoderClass;
    private Class<? extends TransportSelector> selectorClass;
    private int connectCount;
    private List<Peer> servers;

    public RpcClientConfig() {
        transportClient = HttpTransportClient.class;
        encoderClass = JSONEncoder.class;
        decoderClass = JSONDecoder.class;
        selectorClass = RandomTransportSelector.class;
        connectCount = 1;
        servers = Collections.singletonList(new Peer("127.0.0.1", 9999));
    }

    public Class<? extends TransportClient> getTransportClient() {
        return transportClient;
    }

    public void setTransportClient(Class<? extends TransportClient> transportClient) {
        this.transportClient = transportClient;
    }

    public Class<? extends Encoder> getEncoderClass() {
        return encoderClass;
    }

    public void setEncoderClass(Class<? extends Encoder> encoderClass) {
        this.encoderClass = encoderClass;
    }

    public Class<? extends Decoder> getDecoderClass() {
        return decoderClass;
    }

    public void setDecoderClass(Class<? extends Decoder> decoderClass) {
        this.decoderClass = decoderClass;
    }

    public Class<? extends TransportSelector> getSelectorClass() {
        return selectorClass;
    }

    public void setSelectorClass(Class<? extends TransportSelector> selectorClass) {
        this.selectorClass = selectorClass;
    }

    public int getConnectCount() {
        return connectCount;
    }

    public void setConnectCount(int connectCount) {
        this.connectCount = connectCount;
    }

    public List<Peer> getServers() {
        return servers;
    }

    public void setServers(List<Peer> servers) {
        this.servers = servers;
    }
}
